# This is a Windows PowerShell script
# On windows 7, open cmd.exe, input powershell, hit enter, then you can run this script.
# If you use powershell the first time, excute this cmd first: set-executionpolicy remotesigned
# Build mockcpp and it's tests, and at last run all tests.

$MINGW_VER="-G `"MinGW Makefiles`""

function build($build_dir, $src_dir) { 
	if (!(test-path $build_dir)) { mkdir $build_dir }
	cd $build_dir
	Invoke-Expression "cmake $src_dir $MINGW_VER"
	make
}

build build\mockcpp ..\..\tests\3rdparty\mockcpp
cd ..\..

build build\testngpp ..\..\tests\3rdparty\testngpp
cd ..\..

build build\project ..\..
cd ..\..

build build\tests ..\..\tests


#---------------------------------
# run all tests
cd ut

$TESTNGPP_BINARY_DIR="..\..\testngpp\src"
$LISTENER_PATH=Join-Path $TESTNGPP_BINARY_DIR 'listeners'

$ALL_DLL=(ls *.dll -name)-replace ".dll" | where {$_ -ne "testngppstdoutlistener"}

..\..\testngpp\src\runner\testngpp-runner.exe $ALL_DLL -L"$LISTENER_PATH" -l"testngppstdoutlistener -c -v" -m

cd ..\..\..

